/*
 * Copyright (c) 2008 VMware, Inc.
 * Copyright (c) 2009 John Pritchard, WTKX Project Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package wtkx.in;

import wtkx.Application;
import wtkx.collections.Dictionary;
import wtkx.collections.HashMap;
import wtkx.util.Properties;
import wtkx.wtk.ApplicationContext;

import netscape.javascript.JSObject;

import java.awt.Graphics;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;


/**
 * Application context used to execute applications in a web browser.
 *
 * @author gbrown
 */
@SuppressWarnings("deprecation")
public final class Browser
    extends ApplicationContext 
{

    private final Applet hostApplet;


    public Browser(Applet hostApplet,
                   URL origin,
                   Dictionary<String,String> properties, 
                   Application application)
    {
        super(properties,application,origin);
        this.hostApplet = hostApplet;
    }


    public Object eval(String script) {
        try {
            JSObject window = JSObject.getWindow(this.hostApplet);
            return window.eval(script);
        }
        catch (Throwable throwable) {
            throw new UnsupportedOperationException(throwable);
        }
    }
}
